package com.imooc.ecommerce.block_handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import com.imooc.ecommerce.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;

/**
 * 自定义通用的限流处理策略
 *
 * @author zhangshao
 * @since 2023/12/6 20:17
 */
@Slf4j
public class CustomBlockHandler {

    public static CommonResponse<String> commonHandlerBlockException(BlockException ex) {
        log.error("trigger custom block handler:[{}],[{}]", JSON.toJSONString(ex.getRule()), ex.getRuleLimitApp());
        return new CommonResponse<>(-1, "flow rule trigger block exception", null);
    }
}
